#pragma warning disable 0618
using System;
using System.Collections.Generic;
using Table.DataModel;
namespace Table.Dao
{
    public class TableExpressionAtlasDao:DaoBase<TableExpressionAtlas>
    {
        public override string GetFileName()
        {
            return "TableExpressionAtlas.csv";
        }
        public override void BuildIndex()
        {
            if (cacheList != null)
            {
                cachePrimaryInt = new Dictionary<int, TableExpressionAtlas>(cacheList.Count);
            }
            base.BuildIndex();
        }
        public override void AddOneIndex(TableExpressionAtlas model)
        {
            if (!cacheOneIndex.ContainsKey(model.SpriteAsset.ToString()))
            {
                cacheOneIndex[model.SpriteAsset.ToString()] = new List<TableExpressionAtlas>();
            }
            cacheOneIndex[model.SpriteAsset.ToString()].Add(model);
        }
        public override void AddPrimaryIndex(TableExpressionAtlas model)
        {
            #if UNITY_EDITOR
            if(cachePrimaryInt.ContainsKey(model.AtlasId)) UnityEngine.Debug.LogError("数据表id重复:TableExpressionAtlas->id: " + model.AtlasId);
            #endif
            cachePrimaryInt[model.AtlasId] = model;
        }
        protected override TableExpressionAtlas ParseRowData(string[] rowData)
        {
            TableExpressionAtlas data = new TableExpressionAtlas();
            if (!string.IsNullOrEmpty(rowData[0]))
            {
                data.AtlasId = int.Parse(rowData[0]);
            }
            if (!string.IsNullOrEmpty(rowData[1]))
            {
                data.AtlasIcon = rowData[1];
            }
            if (!string.IsNullOrEmpty(rowData[2]))
            {
                data.AtlasName = rowData[2];
            }
            if (!string.IsNullOrEmpty(rowData[3]))
            {
                data.SpriteAsset = rowData[3];
            }
            if (!string.IsNullOrEmpty(rowData[4]))
            {
                data.EmojiNum = int.Parse(rowData[4]);
            }
            if (!string.IsNullOrEmpty(rowData[5]))
            {
                data.FrameNum = int.Parse(rowData[5]);
            }
            if (!string.IsNullOrEmpty(rowData[6]))
            {
                data.EmojiPre = rowData[6];
            }
            if (!string.IsNullOrEmpty(rowData[7]))
            {
                data.IntegrateGT = int.Parse(rowData[7]);
            }
            return data;
        }
    }
}
